package cn.yj.core.business.controller;

import cn.yj.annotation.pagehelper.page.PageUtils;
import cn.yj.admin.frame.AbstractController;
import cn.yj.common.Enums;
import cn.yj.syslog.common.LogType;
import cn.yj.syslog.common.OperateLog;
import cn.yj.core.business.service.IntegralService;
import cn.yj.entity.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author 永健
 * @since 2021-05-07 14:41
 */
@RestController
@RequestMapping("/integral")
public class IntegralController extends AbstractController {

    @Resource
    private IntegralService integralService;


    @RequiresPermissions("integral:list")
    @GetMapping("/water/pageList")
    public R waterPage(@RequestParam Map<String, Object> params) {
        return success(integralService.waterPageList(params, PageUtils.page()));
    }

    @RequiresPermissions("integral:cash:out:list")
    @GetMapping("/water/cashOut/pageList")
    public R waterCashOutPage(@RequestParam Map<String, Object> params) {
        params.put("type", Enums.IntegralWater.TYPE.OUT.name());
        params.put("source", Enums.IntegralWater.SOURCE.CASH_OUT.name());
        return success(integralService.waterPageList(params, PageUtils.page()));
    }

    @RequiresPermissions("integral:cash:out:update")
    @OperateLog(describe = "修改提现积分状态",type = LogType.UPDATE)
    @PostMapping("/water/cashOut/update")
    public R waterCashOutUpdate(@RequestBody Map<String, Object> params) {
        return success(integralService.waterCashOutUpdate(params));
    }

    @RequiresPermissions("integral:cash:out:list")
    @GetMapping("/getWaterStatusSourceType")
    public R getWaterStatusSourceType(){
        return success(integralService.getWaterStatusSourceType());
    }
}
